using Newtonsoft.Json;
using RFS.Domain.PaiShi;
using RFS.Domain.PaiShi.Accounting;
using ycx;

namespace RFS.BizLogic.PaiShi.Accounting
{
    public class OrderBasedAccItem : IOrderBasedAccItem
    {
        public override string ToString()
        {
            return  $"{Summary.PadRight(10)}{RelatedOrderItem.BizId.PadRight(10)}{AmountDebit.ToString().PadLeft(20)}{AmountCredit.ToString().PadLeft(20)} ";
        }

        public override bool Equals(object obj)
        {
            
            if (obj == null) return false;
            if (obj is OrderBasedAccItem ot)return ot.Id.Equals(this.Id);
            
            return false;
        }

        public string Summary { get; set; }
        public Account Account { get; set; }
        
        // [JsonIgnore]
        public IOrderItem RelatedOrderItem { get; set; }
        
        /// <summary>
        /// Jei
        /// </summary>
        public Amount AmountDebit { get; set; }
        
        /// <summary>
        /// dai
        /// </summary>
        public Amount AmountCredit { get; set; }

        public Amount AmountLeft { get; set; }
        public ulong Id { get; set; } = 1.NewSnowflakeId();
    }
}